🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / common / src / commonMain / kotlin / org / meshtastic / core / common / util / DeferredExecution.kt
Displaying Raw • Download
core/common/src/commonMain/kotlin/org/meshtastic/core/common/util/DeferredExecution.kt 2d20cd8a4708e2ef66e98d5259f3a97ec93f240a (2d20cd8a) Text, 1.52 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.common.util
Tff7b72import T7ee787co.touchlab.kermit.Logger
T8b949e/**
* Sometimes when starting services we face situations where messages come in that require computation but we can't do
* that computation yet because we are still waiting for some long running init to complete.
*
* This class lets you queue up closures to run at a later date and later on you can call run() to run all the
* previously queued work.
*/
Tff7b72class T56d364DeferredExecution Tb4b4b4{
Tff7b72private Tff7b72val Te6edf3queue Tff7b72= Te6edf3mutableListOfTff7b72<Tb4b4b4(Tb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTff7b72>Tb4b4b4(Tb4b4b4)
T8b949e/** Queues new work to be executed later. */
Tff7b72fun Td2a8ffaddTb4b4b4(Te6edf3fnTb4b4b4: Tb4b4b4(Tb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTb4b4b4) Tb4b4b4{
Te6edf3queueTb4b4b4.Te6edf3addTb4b4b4(Te6edf3fnTb4b4b4)
Tb4b4b4}
T8b949e/** Runs all work in the queue and clears it. */
Tff7b72fun Td2a8ffrunTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3LoggerTb4b4b4.Te6edf3d Tb4b4b4{ Ta5d6ff"Ta5d6ffRunning deferred execution, numJobs=Tffd700${Te6edf3queueTb4b4b4.Te6edf3sizeTffd700}Ta5d6ff" Tb4b4b4}
Te6edf3queueTb4b4b4.Te6edf3forEach Tb4b4b4{ Tffa657itTb4b4b4(Tb4b4b4) Tb4b4b4}
Te6edf3queueTb4b4b4.Te6edf3clearTb4b4b4(Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.04s